package hosp;
import db.dao.*;
import db.dto.*;
import db.exceptions.*;
import db.factory.*;
import db.jdbc.AbstractDao;
import db.jdbc.OperationDaoImpl;
import db.jdbc.PersonDaoImpl;
import personal.*;
import process.Operation;

import java.lang.reflect.InvocationTargetException;
import java.util.*;

import org.simpleframework.xml.Root;

/**
 * User: Vanil
 * Date: 17.11.2010
 * Time: 12:50:56
 */
@Root
public class Hospital {
    public Collection<Department> departments ;
    public Hospital() {
        this.departments = new ArrayList<Department>();
    }
     public void setDepartments(Collection<Department> departments) {
        this.departments = departments;
    }

    public Collection<Department> getDepartments() {

        return departments;
    }

    public static void main(String[] args) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
    //DoctorDto dto = new DoctorDto();
//        PersonDao dao = new PersonDaoImpl();
//        Department department;
//        Collection<Patient> patientCollection;
        try {
//            PersonDto doctorDto = dao.findWhereLoginEquals("JackLog")[0];;
//            Doctor doctorA = new Doctor((DoctorDto)doctorDto);
//
//            PersonDto doctorDtoB = dao.findByPrimaryKey(2);;
//            Doctor doctorB = new Doctor((DoctorDto)doctorDtoB);
//
//            Collection<Patient> patientCollectionA = doctorA.getPatients();
//            Collection<Patient> patientCollectionB = doctorB.getPatients();
//            OperationDao operDao = new OperationDaoImpl();
//            OperationDto dto = operDao.findByPrimaryKey(1);
//            Operation operation = new Operation(dto);
//            department = doctorA.getDepartment();
//            System.out.println(department);
//            DoctorDao doctorDao = DoctorDaoFactory.create();
//            PersonDto dto = new PersonDto();
//            dto.setLogin("TestPerson5");
//            dto.setName("TestPersonName5");
//            dto.setPassword("TestPass5");
//            DoctorDto doctorDto = new DoctorDto(dto);
//            doctorDto.setExp(6);
//            doctorDto.setIdDepartment(1);
//            doctorDto.setSpeciality("Test Per Doctor5");
//
//            doctorDao.insert(doctorDto);
//            IntakeDao intakeDao = IntakeDaoFactory.create();
//            IntakeDto dto = new IntakeDto();
//            dto.setDateofintake(123456789);
//            dto.setIdDoctor(1);
//            dto.setIdPatient(4);
//            dto.setPriority(1);
//            dto.setComment("Test Intake");
//
//            intakeDao.insert(dto);
//              IntakeDao intakeDao = IntakeDaoFactory.create();
//            IntakeDto[] whereIdDoctorEquals = intakeDao.findWhereIdDoctorEquals(1);
            PersonDao perDao = PersonDaoFactory.create();
            PersonDto dto = perDao.findByPrimaryKey(1);


            Doctor doctor = new Doctor((DoctorDto) dto);
            Collection<Operation> operationCollection = doctor.getOperations();
            Collection<Doctor> doctors = ((Operation) operationCollection.toArray()[0]).getDoctors();
            System.out.println("");

        } catch (DoctorHasOperatinsDaoException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (OperationDaoException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (PersonDaoException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }


    }

}
